Repository navigation
darwin: keep the traffic lights centered when the title changes - #5
Merged
Merged
Conversation
Setting the window title lays the titlebar out again, and AppKit puts the zoom button back at the system's height without posting the frame change keepTrafficLightsCentered listens for. In a custom titlebar taller than the system's, the green button then sits above the other two until the next resize. setWindowTitle: now places the buttons again itself.
xiaoyumuxi
added a commit
to 1lck/Lithe-IDEA
that referenced
this pull request
Nov 11, 2026
窗口标题跟随项目后(815a7f772),AppKit 重新布局标题栏,把绿色按钮放回系统默认高度, 而且不发出帧变化通知,40pt 标题栏里绿色按钮比红、黄两个高 4pt。 Viva 在 Lithe-IDEA/Lithe-viva#5 修复:改标题后重新摆放按钮;desktop/go.mod 固定到 4dd479b。
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
setWindowTitle:on macOS places the traffic lights again after it sets the window title, when the window has a custom titlebar.Why
A new title makes AppKit lay the titlebar out again. During that layout AppKit moves the zoom button back to the system's height, and it posts no
NSViewFrameDidChangeNotificationfor that last move, sokeepTrafficLightsCenterednever sees it. In a custom titlebar taller than the system's, the green button ends up above the red and yellow ones until the next resize. Lithe IDE (1lck/Lithe-IDEA#1799) sets the title when a project opens (Window.SetTitle, #1), so its 40 pt titlebar showed the green button 4 pt higher than the other two.The same layout leaves the close and minimize buttons, and the container, where Viva put them. Only the zoom button moves without a notification.
How it was verified
test -z "$(gofmt -l $(git ls-files '*.go'))": no Go file changed.go vet ./internal/platform/darwinandgo vet -tags vivahead ./internal/platform/darwin ./headless/...go test ./internal/platform/darwin ./app/... ./headless/... -count=1: all pass.TestNativeTrafficLightPlacementAndWindowLevelfails withtraffic light 2 is at y=377.00, the close button at 375.00 after the title changed.go test ./... -count=1: not run in full; only the packages above.Visual evidence
WindowCustomTitlebarwindow withTitlebarHeightabove 28, afterWindow.SetTitle.SetTitleonce it is shown.internal/platform/darwin/testdata/traffic_lights.m.Where the boundary sits
Framework. It is the macOS backend's own titlebar placement.
Cost
Nothing for windows without a custom titlebar. With one, a title change runs
viva_place_traffic_lights, which is idempotent and touches three views.Upstream
vivaui/viva has no
Window.SetTitleyet (#1 was not proposed upstream), so this fix cannot go upstream on its own. It belongs withSetTitlewhen that is proposed.